home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Vault: The Gold Collection
/
Software Vault - The Gold Collection (American Databankers) (1993).ISO
/
cdr26
/
netprog.zip
/
NETPROG.TAR
/
net
/
strecho.c
< prev
next >
Wrap
Text File
|
1989-12-17
|
473b
|
27 lines
/*
* Read a stream socket one line at a time, and write each line back
* to the sender.
*
* Return when the connection is terminated.
*/
#define MAXLINE 512
str_echo(sockfd)
int sockfd;
{
int n;
char line[MAXLINE];
for ( ; ; ) {
n = readline(sockfd, line, MAXLINE);
if (n == 0)
return; /* connection terminated */
else if (n < 0)
err_dump("str_echo: readline error");
if (writen(sockfd, line, n) != n)
err_dump("str_echo: writen error");
}
}